package com.commands;

import java.io.IOException;
import java.util.Vector;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@SuppressWarnings("serial")
public class AddClassServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
	throws IOException {
		HttpSession session = req.getSession();
		Vector<Vector<String>> classes = (Vector<Vector<String>>)session.getAttribute("classes");
		
		if (classes == null) {
			classes = new Vector<Vector<String>>();
		}
		
		/* Name (0), division (1), grade (2), quarter (3), final exam percent (4), current overall percent (5), goal percent (6),
		 * project hours (7), research hours (8), reading hours (9), other hours (10), confidence (11), finals day (12).
		 */
		Vector<String> classNew = new Vector<String>(); 
		classNew.add(req.getParameter("name"));
		classNew.add(req.getParameter("division"));
		classNew.add(req.getParameter("grade"));
		classNew.add(req.getParameter("final_exam_percent"));
		classNew.add(req.getParameter("current_overall_percent"));
		classNew.add(req.getParameter("goal_percent"));
		classNew.add(req.getParameter("project_hours"));
		classNew.add(req.getParameter("research_hours"));
		classNew.add(req.getParameter("reading_hours"));
		classNew.add(req.getParameter("total_hours"));
		classNew.add(req.getParameter("confidence"));
		classNew.add(req.getParameter("finals_day"));
		
		classes.add(classNew);
		session.setAttribute("classes", classes);

		int counter = (Integer)session.getAttribute("counter");
		counter++;
		session.setAttribute("counter", counter);
		if (counter < Integer.parseInt((String)session.getAttribute("num_classes")) + 1)
			resp.sendRedirect("/student/class.jsp");
		else
			resp.sendRedirect("/student/verification.jsp");
		
	}

}